package com.book.item.Im;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.book.item.mapper.UserMapper;
import com.book.item.pojo.User;
import com.book.item.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Service
@Transactional
public class IUserService extends ServiceImpl<UserMapper,User> implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private  HttpServletRequest request;
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
       HttpSession session=request.getSession();
       session.setAttribute("name",s);
        User byUserid = userMapper.findByUserid(s);
        session.setAttribute("user",byUserid);
        return byUserid;

    }
}
